-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add R2 score to metrics #8093
base: dev
Are you sure you want to change the base?
Add R2 score to metrics #8093
Conversation
Signed-off-by: thibaultdvx <[email protected]>
Signed-off-by: thibaultdvx <[email protected]>
Signed-off-by: thibaultdvx <[email protected]>
Signed-off-by: thibaultdvx <[email protected]>
Signed-off-by: thibaultdvx <[email protected]>
Signed-off-by: thibaultdvx <[email protected]>
Signed-off-by: thibaultdvx <[email protected]>
Signed-off-by: thibaultdvx <[email protected]>
/build |
hi @KumoLiu, could you please have a look at this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, leave few comments inline.
from monai.handlers import R2Score | ||
|
||
|
||
class TestHandlerR2Score(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Base on the ci :https://github.com/Project-MONAI/MONAI/actions/runs/10926409391/job/30330218578?pr=8093#step:8:13844
You need skip the tests if no ignite installed.
def _calculate(y_pred: np.ndarray, y: np.ndarray, p: int) -> float: | ||
num_obs = len(y) | ||
rss = np.sum((y_pred - y) ** 2) | ||
tss = np.sum(y**2) - np.sum(y) ** 2 / num_obs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be tss = np.sum((y - np.mean(y)) ** 2)
here?
|
||
class R2Score(IgniteMetricHandler): | ||
""" | ||
Computes :math:`R^{2}` score accumulating predictions and the ground-truth during an epoch and applying `compute_r2_score`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As elsewhere it would help to explain where this is used and what it would be for. The math is explained in the function which is fine so no need here, just a high level idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here if possible to combine this file with the previous.
Fixes #8085.
Description
I created:
R2Metric
andcompute_r2_score
inmonai.metrics
,R2Score
inmonai.handlers
,test_compute_r2_score.py
,test_handler_r2_score.py
andtest_handler_r2_score_dist.py
.I also modified the docs to mention R2 score.
Note:
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.